<?php

namespace app\api\model;

use think\Model;

/**
 * ActivityTimes
 */
class Times extends Model
{
    // 表名
    protected $name = 'special_activity_times';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 字段类型转换
    protected $type = [
        'activity_times' => 'timestamp:Y-m-d H:i:s',
    ];


    public function getRegistTypeAttr($value): array
    {
        if ($value === '' || $value === null) return [];
        if (!is_array($value)) {
            return explode(',', $value);
        }
        return $value;
    }

    public function setRegistTypeAttr($value): string
    {
        return is_array($value) ? implode(',', $value) : $value;
    }

    public function getActorIdentityAttr($value): array
    {
        if ($value === '' || $value === null) return [];
        if (!is_array($value)) {
            return explode(',', $value);
        }
        return $value;
    }

    public function setActorIdentityAttr($value): string
    {
        return is_array($value) ? implode(',', $value) : $value;
    }

    public function Activity(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\api\model\Activity::class, 'special_activity_id', 'id');
    }
}